package com.hanamaki.homework;

import java.util.Scanner;

/**
 * @author edz
 */
public class Demo02 {

    static Scanner scanner = null;

    static {
        scanner = new Scanner(System.in);
    }

    public static void main(String[] args) {
        cri();
        System.out.println("4个整数的平均值是：" + avg());
        System.out.println(three());
    }

    public static void cri() {
        double r = 2.5;
        double PI = 3.14;
        System.out.println("圆的面积：" + (r * r * PI));
        System.out.println("园的周长：" + 2 * PI * r);

        // 宽
        double h = 4.5;
        // 圆柱体的侧面积
        // 长方形的长
        double c = 2 * PI * r;
        // 长方形的面积
        double ca = h * c;
        // 圆的面积
        double cir = (r * r * PI);
        System.out.println("圆柱体的表面积：" + ((2 * cir) + ca));
        System.out.println("圆柱体的体积为：" + ((r * r * PI) * h));
    }

    public static double avg() {
        scanner = new Scanner(System.in);
        double avg = 0;
        int sum = 0;
        for (int i = 1; i < 5; i++) {
            System.out.println("请输入第" + i + "个数字");
            sum += scanner.nextDouble();
        }
        avg = sum / 4;
        return avg;
    }

    public static int three() {
        scanner = new Scanner(System.in);
        System.out.println("请输入整数a的值");
        int a = scanner.nextInt();
        System.out.println("请输入整数b的值");
        int b = scanner.nextInt();
        int result = (a > b) ? (a = (a - b)) : (a = (a + b));
        return result;
    }
}